package edu.jhu.tcj.purfuit;


public class Space {

	/** Category of the space, null if roll again */
	private Category category;
	/** Whether the space is a roll again space */
	private boolean rollAgain;
	/** Whether the space is a 'headquarter' space */
	private boolean headQuarter;
	/** Unique ID */
	private int ID;
	
	/** 
	 * Protected constructor
	 */
	protected Space(int ID, boolean rollAgain, boolean headQuarter) {
		this.ID = ID;
		this.rollAgain = rollAgain;
		this.headQuarter = headQuarter;
	}
	
	/** 
	 * Creates a space with a given category
	 * @param category of the space
	 * @return a new space
	 */
	public static Space createCategorySpace(int ID, Category category, boolean headQuarter) {
		Space space = new Space(ID, false, headQuarter);
		space.category = category;
		return space;
	}
	
	/**
	 * Creates a roll again space.
	 * This space does not have a category
	 * @return a new space
	 */
	public static Space createRollAgainSpace(int ID) {
		Space space = new Space(ID, true, false);
		space.category = null;
		return space;
	}
	
	/**
	 * @return the category of the space, null if roll again
	 */
	public Category getCategory() {
		return category;
	}

	/**
	 * @return true if the space is a roll again space
	 */
	public boolean isRollAgain() {
		return rollAgain;
	}

	/**
	 * @return true if the space is a headquarter space
	 */
	public boolean isHeadQuarter() {
		return headQuarter;
	}
	
	/**
	 * @return true if the space is the center space
	 */
	public boolean isCenterSpace() {
		return false;
	}
	
	/**
	 * Generates a question with the space's category
	 * @return the question
	 */
	public Question generateQuestion() {
		return QuestionFactory.getInstance().generateQuestion(category);
	}
	
	/**
	 * Gets the unique ID for the space;
	 * @return
	 */
	public int getID() {
		return ID;
	}

}
